package com.work.mvc.view.panels.reports;

import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.ui.*;
import com.work.db.entity.LeaveTypeEnum;
import com.work.i18n.Messages;
import com.work.reports.ReportType;

public class TakenLeaveReportPanel extends ReportPanel {

	private static final long serialVersionUID = 6111669223624371222L;

	private static ReportType reportType = ReportType.TAKEN_LEAVE;

	private HorizontalLayout content;

	public TakenLeaveReportPanel() {
		super(Messages.get(reportType.getName()));
	}
	
	private TwinColSelect reportsSelect;
	
	@Override
	protected Component createContent()
	{
		content = new HorizontalLayout();
		content.setSizeFull();

		reportsSelect = new TwinColSelect();
		reportsSelect.setWidth("400px");
		for (LeaveTypeEnum leave : LeaveTypeEnum.values()) {
			reportsSelect.addItem(leave);
			reportsSelect.setItemCaption(leave, leave.getTitle());
		}
		reportsSelect.setNullSelectionAllowed(false);
		reportsSelect.setMultiSelect(true);
		reportsSelect.setImmediate(true);
		reportsSelect.addValueChangeListener((ValueChangeListener) controller);
		
		content.addComponent(reportsSelect);
		content.setComponentAlignment(reportsSelect, Alignment.MIDDLE_CENTER);
		
		return content;
	}

	@Override
	protected ReportType getReportType()
	{
		return reportType;
	}
	
	@Override
	protected boolean isValid()
	{
		return true;
	}
}
